import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class SeverTxt {
    public static void main(String[] args) {
        ServerSocket serverSocket = null;
        Socket socket = null;
        InputStream inputStream = null;
        OutputStream outputStream = null;
        try {
            serverSocket = new ServerSocket(9999);
            socket = serverSocket.accept();
            inputStream = socket.getInputStream();
            String str = null;
            byte[] b = new byte[1024];
            int length = inputStream.read(b);
            while (length != -1) {
                str = new String(b, 0, length);
                System.out.println(str);
                str = str.toUpperCase();
                break;
            }
            socket.shutdownInput();

            outputStream = socket.getOutputStream();
            outputStream.write(str.getBytes());
            socket.shutdownOutput();

            inputStream.close();
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
